package com.redoor.app.stake.common.service.impl;

import com.redoor.app.stake.common.service.RedisService;
import com.redoornetwork.framework.data.redis.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by wangjunlei on 2018/1/24.
 */
@Service
public class RedisServiceImpl implements RedisService {

    @Autowired
    RedisUtils redisUtils;

    @Override
    public boolean add(String key, Object value) {
        return redisUtils.set(key,value);
    }

    @Override
    public boolean add(String key, Object value, long time) {
        return redisUtils.set(key,value,time);
    }

    @Override
    public Object get(String key) {
        return redisUtils.get(key);
    }

    @Override
    public boolean isExists(String key) {
        return redisUtils.exists(key);
    }

    @Override
    public void delete(String key) {
        redisUtils.remove(key);
    }

    public void deleteByPattern(String pattern){
        redisUtils.removePattern(pattern);
    }

    @Override
    public long incr(String key) {
        long incr = redisUtils.incr(key, 1);
        return incr;
    }
}
